package com.wangyh.edit.prettyedit.help;

import com.wangyh.edit.prettyedit.pages.IPageService;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.TextArea;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * 用户个人中心页面
 * @author wangyh
 *
 */
public class VersionPage implements IPageService {

    @Override
    public Node generatePageToRoot(Pane root) {
        VBox vbox = new VBox();
        vbox.setAlignment(Pos.CENTER);
        TextArea test = new TextArea("个人中心页面");
//        StyleUtil.setFont(test, Color.BLACK, 20);
        vbox.getChildren().add(test);

        root.getChildren().add(vbox);
        return root;
    }

    @Override
    public Node generatePage(String[] args) {
        Text text = new Text("欢迎使用PrettyEdit \n" +
                "当前版本：Ver 1.0.1\n" +
                "最新版本请点击下载：\n" +
                "https://gitee.com/prettyedit/pretty-edit/releases/");
        text.setStyle("-fx-font-size: 20px;\n" +
                "    -fx-font-family: \"Arial Black\";\n" +
                "    -fx-position: center;\n" +
                "    -fx-fill: #818181;\n" +
                "    -fx-effect: innershadow( three-pass-box ,rgba(0,0,0,0.7),6, 0.0 , 0 , 2 );");
        text.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                Desktop d = Desktop.getDesktop();
                URI address = null;
                try {
                    address = new URI("https://gitee.com/prettyedit/pretty-edit/releases/");
                    d.browse(address);
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        return text;
    }


}
